# @Time : 2020/7/18 15:43
# @Author : Fioman 
# @Phone : 13149920693

"""
肤色的范围划定为:
色调值在[5,170] 之间
饱和度值在[25,166] 之间
"""
import cv2 as cv
import numpy as np

img = cv.imread("face.png", cv.IMREAD_COLOR)
hsv = cv.cvtColor(img, cv.COLOR_BGR2HSV)
h,s,v = cv.split(hsv)
hueMin = 5
hueMax = 170
maskHue = cv.inRange(h,hueMin,hueMax)

staMin = 25
staMax = 166
maskSta = cv.inRange(s,staMin,staMax)

maskFace = maskHue & maskSta

face = cv.bitwise_and(img,img,mask=maskFace)

cv.imshow("Original",img)
cv.imshow("face",face)
cv.waitKey(0)


